#include <iostream>
#include <string>

using std::cout;
using std::endl;
using std::string;

class Example
{
public:
    Example(int ix = 0, int iy = 0)
    : _ix(ix)
    , _iy(iy)
    {
        cout << "Example(int = 0, int = 0)" << endl;
    }

    template <class T = double>
    virtual T func()
    {
        return (T)(_ix + _iy);
    }
private:
    int _ix;
    int _iy;
};

int main(int argc, char *argv[])
{
    Example ex(10, 20);
    cout << "ex.func() = " << ex.func<double>() << endl;//显示实例化
    cout << "ex.func() = " << ex.func<int>() << endl;//显示实例化
    cout << "ex.func() = " << ex.func() << endl;//隐式实例化
    return 0;
}

